import Vue from 'vue';

export default {
	/**
	 * 弹出选择框
	 * this.actionSheet(this.actions, item => { //已选择的项目
		    this.$emit('input', item.value);

		    this.$emit('change-label', item.name);
        });

	    const actions = Object.freeze([
	        {name: '男', value: 0},
	        {name: '女', value: 1},
	        {name: '未知', value: 2}
	    ]);
	 * @param actions
	 * @param callback
	 */
    actionSheet (actions, callback){
        const ActionSheetConstructor = Vue.extend(require('./action-sheet/index').default);

        this.actionSheetInstance = new ActionSheetConstructor({
            propsData: {
                actions,
                visible: true

            }
        }).$mount();

        document.body.appendChild(this.actionSheetInstance.$el);

        this.actionSheetInstance.$on('on-select', callback);
        this.actionSheetInstance.$on('closed', () => {
            this.actionSheetInstance.$destroy();
            document.body.removeChild(this.actionSheetInstance.$el);
        });
    }
}
